package com.mayikt.decorete.factory;

import com.mayikt.decorete.GatewayComponent;
import com.mayikt.decorete.impl.BasicComponentGateway;
import com.mayikt.decorete.impl.LimitDecorator;
import com.mayikt.decorete.impl.LogDecorator;

import java.io.*;

/**
 * @author 蚂蚁课堂创始人-余胜军QQ644064779
 * @title: FactoryGateway
 * @description: 每特教育独创第五期互联网架构课程
 * @date 2019/5/1421:22
 */
public class FactoryGateway {

    //    public static GatewayComponent getGatewayComponent() {
//        // 1.创建日志装饰类
//        LogDecorator logDecorator = new LogDecorator();
//        LimitDecorator limitDecorator = new LimitDecorator();
//        limitDecorator.setGatewayComponent(logDecorator);
//        // 2.创建被装饰实现类
//        BasicComponentGateway basicComponentGateway = new BasicComponentGateway();
//        logDecorator.setGatewayComponent(basicComponentGateway);
//        return limitDecorator;
//    }
    public static GatewayComponent getGatewayComponent() {
        return new LimitDecorator(new LogDecorator(new BasicComponentGateway()));
    }

    public static void main(String[] args) {
        GatewayComponent gatewayComponent = FactoryGateway.getGatewayComponent();
        gatewayComponent.service();
    }

}
